import axios from '@/utils/axios'

// 获取支付配置商户列表
export function getPayBusinessList(data) {
  return axios({
    url: '/sp_admin/pay_config/getPayBusinessConfigs',
    method: 'post',
    data: data
  })
}

// 获取朴食-农行平台商
export function getPaymanage(data) {
  return axios({
    url: '/sp_admin/pay_config/getBankABCSubMchList?servicerChannelCode=' + data.servicerChannelCode + '&businessId=' + data.businessId,
    method: 'get'
  })
}

// 获取服务商的支付配置
export function getPayServicerConfig(params) {
  return axios({
    url: '/sp_admin/pay_config/getPayServicerConfig',
    method: 'get',
    params: params
  })
}

// 保存服务商的支付配置
export function saveServicerPayConfig(data) {
  return axios({
    url: '/sp_admin/pay_config/saveServicerPayConfig',
    method: 'post',
    data: data
  })
}

// 获取商户支付配置
export function getPayBusinessConfig(params) {
  return axios({
    url: '/sp_admin/pay_config/getPayBusinessConfig',
    method: 'get',
    params: params
  })
}

// 保存商户支付配置
export function savePayBusinessConfig(data) {
  return axios({
    url: '/sp_admin/pay_config/savePayBusinessConfig',
    method: 'post',
    data: data
  })
}

// 获取商户的微信支付普通商户模式配置
export function getPayWxNormalConfig(params) {
  return axios({
    url: '/sp_admin/pay_config/getPayWxNormalConfig',
    method: 'get',
    params: params
  })
}

// 保存商户的微信支付普通商户模式配置
export function savePayWxNormalConfig(data) {
  return axios({
    url: '/sp_admin/pay_config/savePayWxNormalConfig',
    method: 'post',
    data: data
  })
}

// 获取商户的微信支付服务商模式配置
export function getPayWxSubConfig(params) {
  return axios({
    url: '/sp_admin/pay_config/getPayWxSubConfig',
    method: 'get',
    params: params
  })
}

// 保存商户的微信支付服务商模式配置
export function savePayWxSubConfig(data) {
  return axios({
    url: '/sp_admin/pay_config/savePayWxSubConfig',
    method: 'post',
    data: data
  })
}

// 获取商户的威富通支付配置
export function getPayWFTConfig(params) {
  return axios({
    url: '/sp_admin/pay_config/getPayWFTConfig',
    method: 'get',
    params: params
  })
}

// 保存商户的威富通支付配置
export function savePayWFTConfig(data) {
  return axios({
    url: '/sp_admin/pay_config/savePayWFTConfig',
    method: 'post',
    data: data
  })
}

// 获取银联前置支付配置
export function getPayUnionpayFrontConfig(params) {
  return axios({
    url: '/sp_admin/pay_config/getUnionpayFrontConfig',
    method: 'get',
    params: params
  })
}

// 保存银联前置支付配置
export function savePayUnionpayFrontConfig(data) {
  return axios({
    url: '/sp_admin/pay_config/saveUnionpayFrontConfig',
    method: 'post',
    data: data
  })
}

// 获取商户的云卓支付配置
export function getPayYZConfig(params) {
  return axios({
    url: '/sp_admin/pay_config/getYunzhuoConfig',
    method: 'get',
    params: params
  })
}

// 保存商户的云卓支付配置
export function savePayYZConfig(data) {
  return axios({
    url: '/sp_admin/pay_config/saveYunzhuoConfig',
    method: 'post',
    data: data
  })
}

/**
 * @description 获取商户支付方式配置
 * @param { Boolean } name...
 * @return { Boolean } name...
 */

export function getBusinessChannel(businessId) {
  return axios({
    url: '/sp_admin/pay_config/getBizChannelPayConfig' + '?businessId=' + businessId,
    method: 'get'
  })
}

/**
 * @description 保存商户支付方式
 * @param { Boolean } name...
 * @return { Boolean } name...
 */
export function saveBusinessConfig(data) {
  return axios({
    url: '/sp_admin/pay_config/saveBizChannelPayConfig',
    method: 'post',
    data: data
  })
}

// 判断指定商户是否开启支付路由开关
export function isOpenPayRoute(businessId) {
  return axios({
    url: '/sp_admin/pay_config/isOpenPayRoute?businessId=' + businessId,
    method: 'get'
  })
}

// 渠道开通
/**
 * @description 获取商户渠道列表
 * @param { Boolean } name...
 * @return { Boolean } name...
 */

export function getBusinessChannelList(businessId) {
  return axios({
    url: '/sp_admin/pay_config/getBizChannelConfigs' + '?businessId=' + businessId,
    method: 'get'
  })
}

/**
 * @description 获取渠道开通配置
 * @param { Boolean } name...
 * @return { Boolean } name...
 */

export function getChannelsOfSelect() {
  return axios({
    url: '/sp_admin/pay_config/getSvrChannelConfigs',
    method: 'get'
  })
}

// 获取商户渠道详细配置
export function getChannelsDetailConfig(data) {
  return axios({
    url: '/sp_admin/pay_config/getBizChannelConfig' + '?businessId=' + data.businessId + '&code=' + data.code,
    method: 'get'
  })
}

/**
 * @description 增加商户渠道...
 * @param { Boolean } name...
 * @return { Boolean } name...
 */

export function addChannel(data) {
  return axios({
    url: '/sp_admin/pay_config/saveBizChannelConfig',
    method: 'post',
    data: data
  })
}

/**
 * @description 删除渠道...
更新商户渠道配置状态
 * @param { Boolean } name...
 * @return { Boolean } name...
 */

export function deleteChannelById(data) {
  return axios({
    url: '/sp_admin/pay_config/updateBizChannelConfigStatus?businessId=' + data.businessId + '&code=' + data.code + '&status=' + data.status,
    method: 'post'

  })
}
// 修改渠道
export function editChannelById() {
  return axios({
    url: '/editChannelById',
    method: 'get'

  })
}

// 路由规则

/**
 * @description 获取支付路由规则列表...
 * @param { Boolean } name...
 * @return { Boolean } name...
 */

export function paymentRoutrules(data) {
  return axios({
    url: '/sp_admin/pay_config/getBizPayRoutesConfig',
    method: 'post',
    data: data

  })
}

// 获取支付路由列表
export function getPayRouterList(data) {
  return axios({
    url: '/sp_admin/pay_config/getPayRouteRules',
    method: 'post',
    data: data

  })
}

// 更新支付路由规则状态

export function updatePayRouteRuleStatus(data, businessId) {
  return axios({
    url: '/sp_admin/pay_config/updatePayRouteRuleStatus?businessId=' + businessId,
    method: 'post',
    data: data

  })
}

/**
 * @description 获取门店列表...
 * @param { Boolean } name...
 * @return { Boolean } name...
 */

export function getStoreTree(param) {

}

/**
 *  保存路由规则
 */

export function savePayRouteRule(data) {
  return axios({
    url: '/sp_admin/pay_config/savePayRouteRule',
    method: 'post',
    data: data

  })
}
// 获取所有门店列表
export function getAllStore(businessId) {
  return axios({
    url: '/sp_admin/business/shop/all' + '?businessId=' + businessId,
    method: 'post'
  })
}

// 获取所有设备
export function getAllDevice(businessId) {
  return axios({
    url: '/sp_admin/business/device/all' + '?businessId=' + businessId,
    method: 'get'
  })
}

// 设置路由支付开关
export function setRouterRuleSwitch(data) {
  return axios({
    url: '/sp_admin/pay_config/saveOpenPayRoute' + '?businessId=' + data.businessId + '&openPayRoute=' + data.openPayRoute,
    method: 'post'
  })
}

// 删除路由规则
export function deletePayRouter(data, businessId) {
  console.log(businessId)
  return axios({
    url: '/sp_admin/pay_config/updatePayRouteRuleStatus?businessId=' + businessId,
    method: 'post',
    data: data
  })
}

// 获取支付营销配置
export function getPayMarketingConfig(data) {
  return axios({
    url: '/sp_admin/pay_config/getPayMarketingConfig',
    method: 'post',
    data: data
  })
}

// 保存支付营销配置
export function savePayMarketingConfig(data) {
  return axios({
    url: '/sp_admin/pay_config/savePayMarketingConfig',
    method: 'post',
    data: data
  })
}

// 获取支付费率配置列表
export function getPayRateConfigs(data) {
  return axios({
    url: '/sp_admin/pay_config/getPayRateConfigs?rateType=' + data.rateType + '&businessId=' + data.businessId,
    method: 'get'

  })
}

// 批量保存支付费率配置
export function savePayRateConfigs(data) {
  return axios({
    url: '/sp_admin/pay_config/savePayRateConfigBatch',
    method: 'post',
    data: data
  })
}

// 询授权结果
export function getAuthResult(scene) {
  return axios({
    url: '/sp_admin/pay_config/getAuthResult?scene=' + scene,
    method: 'get'
  })
}

// 拉取已获得授权的商家
export function getAuthManage(data) {
  return axios({
    url: '/sp_admin/pay_config/getAuthBusiness?servicerChannelCode=' + data.servicerChannelCode + '&businessId=' + data.businessId,
    method: 'post'
  })
}
// 获取授权二维码
export function generateQrCode(data) {
  return axios({
    url: '/sp_admin/pay_config/getAuthQrcode?servicerChannelCode=' + data.servicerChannelCode + '&businessId=' + data.businessId + '&userName=' + data.userName,
    method: 'post'
  })
}

// 获取威富通密钥
export function generateRsaKey() {
  return axios({
    url: '/sp_admin/pay_config/getRsaKey',
    method: 'post'
  })
}

// 获取分账接收方列表
export function saveChannelProfitReceiver(data) {
  return axios({
    url: '/sp_admin/pay_config/saveChannelProfitReceiver',
    method: 'post',
    data: data
  })
}
// 获取渠道分账接收方
export function getChannelProfitReceivers(data) {
  return axios({
    url: '/sp_admin/pay_config/getChannelProfitReceivers?channelCode=' + data.channelCode + '&businessId=' + data.businessId,
    method: 'get'
  })
}
// 更新渠道分账接收方状态
export function updateChannelProfitReceiver(data) {
  return axios({
    url: '/sp_admin/pay_config/updateChannelProfitReceiverStatus?account=' + data.account + '&businessId=' + data.businessId + '&channelCode=' + data.channelCode + '&status=' + data.status,
    method: 'post'
  })
}
// 获取分账配置渠道
export function getProfitConfigChannels(businessId) {
  return axios({
    url: '/sp_admin/pay_config/getProfitConfigChannels?businessId=' + businessId,
    method: 'get'
  })
}

